If a bookmark doesn't have an explicit label, use the display name of the file
authorFederico Mena Quintero <federico@gnome.org>
Fri, 7 Sep 2012 19:36:05 +0000 (14:36 -0500)
committerFederico Mena Quintero <federico@gnome.org>
Fri, 7 Sep 2012 19:36:05 +0000 (14:36 -0500)
We query the file info for display name and icon synchronously.  If it becomes a problem,
we'll make it async, more in line with NautilusBookmark.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
gtk/gtkplacessidebar.c

index 0ac7d013bac56fa9f45e51cf1452066089c40989..bb1eb855254620ae969b0ac896faa9d0db7567fd 100644 (file)
@@ -910,6 +910,8 @@ update_places (GtkPlacesSidebar *sidebar)
        bookmarks = _gtk_bookmarks_manager_list_bookmarks (sidebar->bookmarks_manager);
 
        for (sl = bookmarks, index = 0; sl; sl = sl->next, index++) {
+               GFileInfo *info;
+
                root = sl->data;
 
 #if 0
@@ -932,23 +934,36 @@ update_places (GtkPlacesSidebar *sidebar)
                nautilus_file_unref (file);
 #endif
 
-               bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root);
-               icon = NULL; /* FIXME: icon = nautilus_bookmark_get_icon (bookmark); */
-               mount_uri = g_file_get_uri (root);
-               tooltip = g_file_get_parse_name (root);
+               /* FIXME: we are getting file info synchronously.  We may want to do it async at some point. */
+               info = g_file_query_info (root,
+                                         "standard::display-name,standard::icon",
+                                         G_FILE_QUERY_INFO_NONE,
+                                         NULL,
+                                         NULL); /* NULL-GError */
 
-               add_place (sidebar, PLACES_BOOKMARK,
-                          SECTION_BOOKMARKS,
-                          bookmark_name, icon, mount_uri,
-                          NULL, NULL, NULL, index,
-                          tooltip);
+               if (info) {
+                       bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root);
 
-               if (icon)
-                       g_object_unref (icon);
+                       if (bookmark_name == NULL)
+                               bookmark_name = g_strdup (g_file_info_get_display_name (info));
 
-               g_free (mount_uri);
-               g_free (tooltip);
-               g_free (bookmark_name);
+                       icon = g_file_info_get_icon (info);
+
+                       mount_uri = g_file_get_uri (root);
+                       tooltip = g_file_get_parse_name (root);
+
+                       add_place (sidebar, PLACES_BOOKMARK,
+                                  SECTION_BOOKMARKS,
+                                  bookmark_name, icon, mount_uri,
+                                  NULL, NULL, NULL, index,
+                                  tooltip);
+
+                       g_free (mount_uri);
+                       g_free (tooltip);
+                       g_free (bookmark_name);
+
+                       g_object_unref (info);
+               }
        }
 
        g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL);